<div class="bjui-pageContent workflow-create">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">单项详情</h3>
        </div>
        <div class="panel-body">
            <table class="table table-border table-striped workflow_log_list">
                @foreach ( $workflow_log_list as $workflow_log)
                    <tr>
                        <td>{{  $workflow_log['operator_name'] }} <br> <img src="http://oa.100dp.com/templet/admin2013/resources/images/jiantou.png" alt=""></td>
                        <td>{{  $workflow_log['note']}}
                            @if($workflow_log['note'] === '转派') {{ '(' . $workflow_log['assignee_name'] . ')' }} @endif
                        </td>
                        <td>{{$workflow_log['assignee_name']}}</td>
                    </tr>
                @endforeach
            </table>
            {{-- 请假流程 start --}}
            <form action="admin/administration/workflow/create/doc" data-toggle="ajaxform" type="post">
                <input type="hidden" name="oa_contacts_id" value="1">
                <table class="table table-border">
                    <tr>
                        <td colspan="4">流程单号:
                            <div class="row-input">
                                <input type="text" name="serial_number" data-rule="required" value="{{ $serial_number }}" readonly>
                            </div>
                        </td>
                    </tr>
                    <tr><td colspan="4">流程标题: <input type="text" name="title" data-rule="required" value="{{ $flow_info['title'] }}" disabled></td></tr>
                    <tr><td colspan="4"><textarea name="content" data-rule="required" disabled>{{ $flow_info['content'] }}</textarea></td></tr>
                    {{--<tr>--}}
                        {{--<td colspan="2">--}}
                            {{--抄 送: <input type="text" style="width: 200px" name="verifier" data-rule="required" value="{{ $flow_info['operator_name'] }}" disabled>--}}
                        {{--</td>--}}
                        {{--<td colspan="2">--}}
                            {{--终 审 人: <input type="text" style="width: 200px" name="days_scope" data-rule="required"  value="{{ $flow_info['operator_name'] }}" disabled>--}}
                        {{--</td>--}}
                    {{--</tr>--}}
                    @if (count($flow_info['file_list']))
                        <tr>
                            <td colspan="4">
                                附件: @foreach($flow_info['file_list'] as $file)
                                    @if($file['type'] == 1)
                                        <a data-toggle="dialog" style="cursor:pointer;"
                                           data-options="{id:'detail-rb-master-{{$file['id']}}', title:'查看图片',max:true,image:'{{$file['url']}}'}">
                                            <img src="{{$file['url']}}" width="150px" height="100px">
                                        </a>
                                    @else
                                        <a href="{{$file['url']}}"></a>
                                    @endif
                                @endforeach
                            </td>
                        </tr>
                    @endif
                    <tr>
                        <td colspan="4">
                            @if ( $is_able_to_handle == 1)
                                @include('admin.widgets.address-list',['findgrid_contacts_id' => 'assignee_id','findgrid_address_list_name'=>'assignee_id_input'] )
                                <button type="button" class="btn btn-blue btn-copy">抄送</button>
                                <button type="button" class="btn btn-blue btn-redeploy">转派</button>
                                <button type="button" class="btn btn-blue btn-pass">通过</button>
                                <button type="button" class="btn btn-blue btn-reject">拒绝</button>
                            @endif
                        </td>
                    </tr>
                </table>
            </form>
            {{--请假流程 end--}}
        </div>
    </div>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">取消</button>
        </li>
        {{--<li>--}}
        {{--<button type="submit" class="btn-default" data-icon="save">保存</button>--}}
        {{--</li>--}}
    </ul>
</div>
<script>
    ;(function(){
        var id = {{$id}};
        //抄送
        $.CurrentNavtab.find('.btn-copy').on('click',function(){
            var  copy_to_ids = $(this).siblings("input").val();
            if(! copy_to_ids){
                BJUI.alertmsg('warn', '请选择抄送人员');
                return false;
            }

            BJUI.ajax('doajax', {
                url: 'admin/administration/workflow/copy',
                type:"post",
                data:{
                    workflow_id:id,
                    copy_to_ids:copy_to_ids
                },
                loadingmask: true,
                okCallback: function(json, options) {
//                    console.log('返回内容：\n'+ JSON.stringify(json))
                }
            })
        });
        //转派
        $.CurrentNavtab.find('.btn-redeploy').on('click',function(){
            var assignee_id = $(this).siblings("input").val();
            if(!assignee_id){
                BJUI.alertmsg('warn', '请选择转派人员');
                return false;
            }
            BJUI.ajax('doajax', {
                url: 'admin/administration/workflow/handle',
                type:"post",
                data:{
                    workflow_id:id,
                    dispose_code:'1001',
                    assignee_id:assignee_id
                },
                loadingmask: true,
                okCallback: function(json, options) {
//                    console.log('返回内容：\n'+ JSON.stringify(json))
                    BJUI.navtab('closeCurrentTab');
                    $('#todo-list').datagrid('refresh', true);
                }
            })
        });
        //通过
        $.CurrentNavtab.find('.btn-pass').on('click',function(){
            BJUI.ajax('doajax', {
                url: 'admin/administration/workflow/handle',
                type:"post",
                data:{
                    workflow_id:id,
                    dispose_code:'1100'
                },
                loadingmask: true,
                okCallback: function(json, options) {
//                    console.log('返回内容：\n'+ JSON.stringify(json))
                    BJUI.navtab('closeCurrentTab');
                    $('#todo-list').datagrid('refresh', true);
                }
            })
        });
        //拒绝
        $.CurrentNavtab.find('.btn-reject').on('click',function(){
            BJUI.ajax('doajax', {
                url: 'admin/administration/workflow/handle',
                type:"post",
                data:{
                    workflow_id:id,
                    dispose_code:'1200'
                },
                loadingmask: true,
                okCallback: function(json, options) {
//                    console.log('返回内容：\n'+ JSON.stringify(json))
                    BJUI.navtab('closeCurrentTab');
                    $('#todo-list').datagrid('refresh', true);
                }
            })
        });

    })();
</script>
<style>
    .workflow-create .table{
        max-width: 800px;
    }
    .workflow-create .table th,.workflow-create .table td{
        padding: 20px 0;
    }
    .workflow-create .workflow_log_list td{
        padding: 10px 0;
    }

</style>